package com.frank.oj.service.entity.group.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.frank.model.entity.common.Announcement;
import com.frank.oj.mapper.GroupAnnouncementMapper;
import com.frank.oj.model.vo.AnnouncementVO;
import com.frank.oj.service.entity.group.GroupAnnouncementEntityService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author frank
 * @Date 2024/5/4
 */
@Service
public class GroupAnnouncementEntityServiceImpl extends ServiceImpl<GroupAnnouncementMapper, Announcement> implements GroupAnnouncementEntityService {
    @Resource
    private GroupAnnouncementMapper groupAnnouncementMapper;
    @Override
    public IPage<AnnouncementVO> getAnnouncementList(Integer limit, Integer currentPage, Long gid) {

        IPage<AnnouncementVO> iPage = new Page<>(currentPage, limit);

        List<AnnouncementVO> announcementList = groupAnnouncementMapper.getAnnouncementList(iPage, gid);

        return iPage.setRecords(announcementList);
    }

    @Override
    public IPage<AnnouncementVO> getAdminAnnouncementList(Integer limit, Integer currentPage, Long gid) {
        IPage<AnnouncementVO> iPage = new Page<>(currentPage, limit);

        List<AnnouncementVO> announcementList = groupAnnouncementMapper.getAdminAnnouncementList(iPage, gid);

        return iPage.setRecords(announcementList);
    }
}
